{% extends 'base.html' %}

{% block contents %}

<fieldset>

  {% if insert_many %}
    <div class="fieldset_header">Add several movies</div>
  {% else %}
    {% if movie.review_mode or review_mode %}
      {% if update_mode %}        
      <div class="fieldset_header">Update details your "{{movie.title_}}"-review</div>
      {% else %}
      <div class="fieldset_header">Add a new review</div>
      {% endif %}

    {% else %}  
      {% if update_mode %}        
      <div class="fieldset_header">Update details about "{{movie.title_}}"</div>
      {% else %}
      <div class="fieldset_header">Add a new movie</div>
      {% endif %}
    {% endif %}
  {% endif %}

    {% if message %}        
    <div class="form_message">{{message}}</div>
    {% endif %}
    
      {% if insert_many or movie.review_mode or review_mode %}        
<form action="/add/" method="post">
      {% else %}
<form action="." method="post">
      {% endif %}
      
    {% if movie.key %}
    <input type="hidden" name="movie_key" value="{{movie.key}}"/>
    {% endif %}

    {% if insert_many %}
    <input type="hidden" name="insert_many" value="1"/>
    <label for="movie_titles">Movie titles ( one title per line ):</label><br/>
    <textarea rows=30 cols=60 name="movie_titles"></textarea>
    <P/>
  
    {% else %}  
    <label for="title">Title:</label><br/>
    <input type="text" size=50 name="title" value="{{movie.title_}}"/>
    <p/>
    
    <label for="buy_url">Enter a link to where you bought it:</label><br/>
    <input type="text" size=50 name="buy_url" value="{{movie.buy_url_}}"/>
    <p/>

    <label for="imdb_url">Enter a link to <a href="http://www.imdb.com">ImDb</a>:</label><br/>
    <input type="text" size=50 name="imdb_url" value="{{movie.imdb_url_}}"/>
    <p/>

    <label for="comments">Comments:</label><br/>
    <textarea rows=10 cols=60 name="comments">{{movie.comments_}}</textarea>
    <P/>
    {% endif %}
    
    {% if movie.review_mode or review_mode %}
    <input type="hidden" name="status" value="5"/>
    {% else %}  
      <label for="media type">Media type:</label><br/>
      {% ifequal movie.media_type 1 %}        
      <input type="radio" name="media_type" value="1" checked>Blu-ray<br/>
      {% else %}
      <input type="radio" name="media_type" value="1">Blu-ray<br/>
      {% endifequal %}
      {% ifequal movie.media_type 2 %}        
      <input type="radio" name="media_type" value="2" checked>DVD<br/>
      {% else %}
      <input type="radio" name="media_type" value="2">DVD<br/>
      {% endifequal %}
      {% ifequal movie.media_type 3 %}        
      <input type="radio" name="media_type" value="3" checked>Other<br/>
      {% else %}
      <input type="radio" name="media_type" value="3">Other<br/>
      {% endifequal %}
      <p/>
      
      <label for="status">Status:</label><br/>
      {% ifequal movie.status 1 %}            
      <input type="radio" name="status" value="1" checked>Ordered<br/>
      {% else %}
      <input type="radio" name="status" value="1">Ordered<br/>
      {% endifequal %}
      {% ifequal movie.status 2 %}            
      <input type="radio" name="status" value="2" checked>Available<br/>
      {% else %}
      <input type="radio" name="status" value="2">Available<br/>
      {% endifequal %}
      {% ifequal movie.status 3 %}            
      <input type="radio" name="status" value="3" checked>Unavailable<br/>
      {% else %}
      <input type="radio" name="status" value="3">Unavailable<br/>
      {% endifequal %}
      {% ifequal movie.status 4 %}            
      <input type="radio" name="status" value="4" checked>Wanted<br/>
      {% else %}
      <input type="radio" name="status" value="4">Wanted<br/>
      {% endifequal %}
      <p/>
  
      {% if movie.can_be_sold %}            
      <input type="checkbox" name="can_be_sold" checked="true"/>
      {% else %}
      <input type="checkbox" name="can_be_sold"/>
      {% endif %}    
      <label for="can_be_sold">Can be sold.</label>
  
      <label for="suggested_price">Suggested price:</label>    
      <input type="text" name="suggested_price" size=5 value="{{ movie.suggested_price }}"/>
      <br/>
  
      {% if movie.can_be_borrowed %}            
      <input type="checkbox" name="can_be_borrowed" checked="true"/>
      {% else %}
      <input type="checkbox" name="can_be_borrowed"/>
      {% endif %}
      <label for="can_be_borrowed">Can be borrowed</label>
      <br/>
  
      {% if movie.can_be_swapped %}            
      <input type="checkbox" name="can_be_swapped" checked="true"/>
      {% else %}
      <input type="checkbox" name="can_be_swapped"/>
      {% endif %}
      <label for="can_be_swapped">Can be swapped</label>
      <br/>
    {% endif %}

    {% if movie.is_public %}            
    <input type="checkbox" name="is_public" checked="true"/>
    {% else %}
    <input type="checkbox" name="is_public"/>
    {% endif %}
    <label for="is_public">Public</label>
    <P/>
    
    Genre:<br/>
    {% for v in genres.values %}
    {% ifequal movie.genre_text v %}
    <input type="radio" name="genre" value="{{v}}" checked/>{{v}}
    {% else %}
    <input type="radio" name="genre" value="{{v}}"/>{{v}}
    {% endifequal %}<br/>
    {% endfor %}
    <P/>

<input type="submit" value="Update entry" />

</form>
</fieldset>

{% endblock %}